package string;

public class 路径加密 {
    class Solution {

        private static final String REPLACE_SPACE_VALUE = "%20";

        public String replaceSpace(String s) {
            StringBuilder builder = new StringBuilder();
            char[] ch = s.toCharArray();
            for (char c : ch) {
                if (c == ' ') {
                    builder.append(REPLACE_SPACE_VALUE);
                } else {
                    builder.append(c);
                }
            }

            return builder.toString();
        }
    }
    class Solution2{
        public String pathEncryption(String path) {
            StringBuilder res = new StringBuilder();
            for (Character c : path.toCharArray()){
                if(c == '.')
                    res.append(' ');
                else
                    res.append(c);
            }
            return res.toString();
        }
    }
}
